<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
       function findLongest(str)
       {
           let set = new Set();
           let maxLen = 0;
           let maxStr = "";
           let left = 0;
           let right = 0;
           for(;right<str.length;right++)
           {
               while(set.has(str[right]))
               {
                    set.delete(str[left]);
                    left++;
               }
               set.add(str[right]);
               if(right-left+1>maxLen)
               {
                  maxLen = right-left+1;
                  maxStr = str.slice(left,maxLen);
               }
           }
           
           maxStr = str.slice(left);
           return maxStr;
       }
       let str = 'abcnmlopabbbbabc123456789';
       console.log(findLongest(str));
    </script>
</body>
</html>